package lab03.test07;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Test {
    public static void main(String[] args){
        File f=new File("Book.zip");
        File dir=new File("book");
        byte b[]=new byte[100];
        dir.mkdir();
        try {
            ZipInputStream in= null;
            try {
                in = new ZipInputStream(new FileInputStream(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            ZipEntry zipEntry=null;
            try {
                while ((zipEntry=in.getNextEntry())!=null){
                    File file=new File(dir,zipEntry.getName());
                    FileOutputStream out=new FileOutputStream(file);
                    int n=1;
                    System.out.println(file.getAbsoluteFile()+"内容");
                    while ((n=in.read(b,0,100))!=-1){
                        String str=new String(b,0,n);
                        System.out.println(str);
                        out.write(b,0,n);
                    }
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            in.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



